<template>
  <view class="">
    <view class="header"> </view>
    <view class="main">
      <view class="circleBox">
        <u-icon name="checkmark-circle-fill" color="#004399" size="80"></u-icon>
      </view>
      <view class="statusTitle">下单成功</view>
      <view class="statusTitle2">请联系客服发货</view>
      <view class="line"></view>
      <view class="nameBox">
        <image class="img" :src="orderInfo?.goodUrl" mode=""></image>
        <view class="nameInfo">
          <view class="f">{{ orderInfo?.goodTitle || "" }}</view>
          <view class="t">
            <view class="l"></view>
            <view class="price">
              <text>￥</text>
              {{ orderInfo?.actualAmount || "" }}
            </view>
          </view>
        </view>
      </view>
      <view class="infoList">
        <view class="infoItem">
          <view class="label">订单编号</view>
          <view class="value">{{ orderInfo?.orderNo }}</view>
        </view>
        <view class="infoItem">
          <view class="label">订单金额</view>
          <view class="value">￥{{ orderInfo?.actualAmount }}</view>
        </view>
        <view class="infoItem">
          <view class="label">下单时间</view>
          <view class="value">{{ dayjs(orderInfo?.gmtCreate).format("YYYY-MM-DD HH:mm:ss") }}</view>
        </view>
      </view>
    </view>
    <view class="bottomBox">
      <u-button text="返回首页" @click="goPage" color="#02409a"></u-button>
    </view>
  </view>
</template>

<script setup lang="ts">
import { onBeforeMount, ref } from "vue";
import dayjs from "dayjs";
const { orderId } = defineProps<{
  orderId: string;
}>();
const orderInfo = ref();
onBeforeMount(async () => {
  const res = await selectShopOrderByOrderNo({ orderNo: orderId });
  orderInfo.value = res.shopOrderInfo;
});
const goPage = () => {
  uni.switchTab({
    url: "/pages/home/home",
  });
};
const cancelOrderFn = async () => {
  let url = "";
  uni.showToast({
    title: "取消成功",
    icon: "success",
    position: "top",
    success() {
      uni.redirectTo({
        url,
      });
    },
  });
};
</script>

<style lang="less" scoped>
.header {
  height: 300rpx;
  background: linear-gradient(180deg, #02409a 0%, #02409a 82%, rgba(2, 64, 154, 0.1) 100%);
}
.main {
  background: #ffffff;
  border-radius: 20rpx;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: -60rpx;

  .circleBox {
    width: 120rpx;
    height: 120rpx;
    background: #f4f8fb;
    border-radius: 50%;
    border: 30rpx solid #f4f8fb;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: -90rpx;
  }

  .statusTitle {
    font-size: 44rpx;
    font-weight: 800;
    color: #303133;
    margin-top: 50rpx;
  }
  .statusTitle2 {
    font-size: 30rpx;
    margin-top: 20rpx;
  }

  .line {
    width: 100%;
    height: 1rpx;
    border-bottom: 1rpx dashed #f3f3f3;
    margin: 60rpx 0;
    position: relative;

    &:before {
      content: "";
      position: absolute;
      left: -15rpx;
      bottom: -16rpx;
      width: 30rpx;
      height: 30rpx;
      border-radius: 50%;
      background: #f4f8fb;
    }

    &::after {
      content: "";
      position: absolute;
      right: -15rpx;
      bottom: -16rpx;
      width: 30rpx;
      height: 30rpx;
      border-radius: 50%;
      background: #f4f8fb;
    }
  }

  .infoList {
    box-sizing: border-box;
    width: 100%;
    padding: 0 24rpx;
  }

  .infoItem {
    display: flex;
    justify-content: space-between;
    color: #303133;
    font-size: 28rpx;
    line-height: 100rpx;

    .value {
      width: 79%;
      font-weight: 700;
    }
  }
}
.bottomBox {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100rpx, 1fr)); /* 自适应列布局 */
  gap: 10px; /* 子元素之间的间距 */
}
.nameBox {
  width: 94%;
  border-radius: 16rpx;
  display: flex;
  align-items: center;
  margin-bottom: 20rpx;

  .img {
    width: 144rpx;
    height: 144rpx;
    margin-right: 24rpx;
    background: #bebebe;
  }
  .nameInfo {
    width: calc(100% - 168rpx);
    .f {
      font-size: 28rpx;
      font-weight: 500;
      color: #333333;
      line-height: 36rpx;
      text {
        margin-right: 24rpx;
      }
    }
    .s {
      font-size: 26rpx;
      color: #bebebe;
      line-height: 36rpx;
      margin-top: 8rpx;
    }
    .t {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-top: 20rpx;
      .l {
        font-size: 24rpx;
        color: #bebebe;
        line-height: 34rpx;
      }
      .price {
        font-size: 30rpx;
        font-weight: bold;
        color: #333333;
        line-height: 34rpx;
        text {
          font-size: 24rpx;
          font-weight: 500;
          margin-right: -15rpx;
        }
      }
    }
  }
}
</style>
